Skip to content

Inline image intrinsics#523

Merged
Firestar99 merged 3 commits intomainfrom
inline_image_intrinsics
Feb 4, 2026
Merged

Inline image intrinsics#523
Firestar99 merged 3 commits intomainfrom
inline_image_intrinsics

Conversation

@Firestar99
Copy link
Member

@Firestar99 Firestar99 commented Feb 4, 2026

Inline all image intrinsics, helps with naga transpiling. Currently, all texel writes fail to transpile as the OpImageWrite is in a separate function that is called, inlining that call makes naga happy.

Also cargo update to fix cargo deny vuln reporting, insignificant for us, it's just the Android example.

Close #522

Additional context

See #522 (comment):

While I generally agree that this is technically a naga problem of not parsing valid spirv, I also like to look at the spirv we're emitting vs spirv emitted by glslc, to figure out what weird thing we're doing that may be breaking naga. And indeed, we are kinda weird.

Here I've transpiled the output of a compiletest just writing an image to glsl with spirv-cross -V:

#version 450
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;

layout(set = 0, binding = 0, std430) readonly buffer fill_color
{
    vec4 _m0;
} fill_color_1;

layout(set = 0, binding = 1) uniform readonly writeonly image2D image;

void _spirv_std_image_Image_f32_1_2_0_0_2_0_4_write_u32_glam_u32_uvec2_UVec2_(writeonly image2D _32, uvec2 _33, vec4 _34)
{
    imageStore(_32, ivec2(uvec2(_33)), _34);
}

void main()
{
    vec4 _29 = fill_color_1._m0;
    _spirv_std_image_Image_f32_1_2_0_0_2_0_4_write_u32_glam_u32_uvec2_UVec2_(image, uvec2(gl_GlobalInvocationID.xy), _29);
}

First, it'll fail to compile cause our image is both read_only and write_only. Removing read_only, you'll notice that our imageStore does indeed not operate on a global variable but on a parameter passed to the function. If we inline that function call, it works.

So yea... the fix is to add #[inline] to all the image instrinsics on our side

@Firestar99 Firestar99 force-pushed the inline_image_intrinsics branch from aae564a to 1bb1187 Compare February 4, 2026 11:02
@Firestar99 Firestar99 marked this pull request as ready for review February 4, 2026 11:27
@Firestar99 Firestar99 enabled auto-merge February 4, 2026 12:11
Copy link
Collaborator

@LegNeato LegNeato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@Firestar99 Firestar99 added this pull request to the merge queue Feb 4, 2026
Merged via the queue into main with commit 7a0b4b3 Feb 4, 2026
13 checks passed
@Firestar99 Firestar99 deleted the inline_image_intrinsics branch February 4, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Image store parameters are invalid - Not a global variable

2 participants